var Utils = {};

Utils.isIE = !!window.ActiveXObject;
Utils.isOldIE = !window.addEventListener;
Utils.isOpera = !!window.opera;

Utils.bind = function (fn, thisObj){
    return function (){
        return fn.apply(thisObj, arguments);
    };
};

Utils.stringRepeat = function (str, count){
    return new Array(count + 1).join(str);
};

Utils.extend = function (c, b){
    var cp = c.prototype;
    var bp = b.prototype;
    for (var k in bp) {
        if (!(k in cp)) {
            cp[k] = bp[k];
        }
    }
};

Utils.format = function (tpl, ctx){
    return tpl.replace(/#\{([^}]+)\}/g, function (m, p1){
        return ctx[p1];
    });
};

var _lastGuid = -1;
Utils.guid = function (obj){
    return obj._guid || (obj._guid = 'qe:' + ++_lastGuid);
};

Utils.removeItem = function (array, item){
    var k = array.length;
    while (k --) {
        if (array[k] === item) {
            array.splice(k, 1);
            return k;
        }
    }
};
